package com.cmcc.aregister.ui.activity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.EditText;
import android.widget.FrameLayout.LayoutParams;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cmcc.aregister.R;
import com.cmcc.aregister.cs.asntask.InterfaceUtils.DataCallback_other;
import com.cmcc.aregister.cs.asntask.MyAsynaTask;
import com.cmcc.aregister.cs.constant.Arguments;
import com.cmcc.aregister.cs.constant.ConfigUtilHelper;
import com.cmcc.aregister.cs.constant.GlobalSetting;
import com.cmcc.aregister.cs.http.HttpAsyncTask;
import com.cmcc.aregister.cs.model.AreaModel;
import com.cmcc.aregister.cs.model.AreaResultModel;
import com.cmcc.aregister.cs.model.DepModel;
import com.cmcc.aregister.cs.model.DepResultModel;
import com.cmcc.aregister.cs.model.Department;
import com.cmcc.aregister.cs.model.DocInfoModel;
import com.cmcc.aregister.cs.model.DocModel;
import com.cmcc.aregister.cs.model.DocResultModel;
import com.cmcc.aregister.cs.model.Doctor;
import com.cmcc.aregister.cs.model.FamilyModel;
import com.cmcc.aregister.cs.model.Hospital;
import com.cmcc.aregister.cs.model.HospitalInfoModel;
import com.cmcc.aregister.cs.model.HospitalModel;
import com.cmcc.aregister.cs.model.HospitalResultModel;
import com.cmcc.aregister.cs.model.Schedule;
import com.cmcc.aregister.cs.model.ScheduleModel;
import com.cmcc.aregister.cs.model.ScheduleResultModel;
import com.cmcc.aregister.cs.util.PotoalParcelable;
import com.cmcc.aregister.cs.util.Utils;
import com.cmcc.aregister.ui.adapter.ChoiceAreaAdapter;
import com.cmcc.aregister.ui.adapter.ChoiceDepartmentAdapter;
import com.cmcc.aregister.ui.adapter.ChoiceDoctorAdapter;
import com.cmcc.aregister.ui.adapter.ChoiceHospitalAdapter;
import com.cmcc.aregister.ui.adapter.ChoiceOtherDepAdapter;
import com.cmcc.aregister.ui.adapter.ChoiceOtherDocAdapter;
import com.cmcc.aregister.ui.adapter.ChoiceOtherHospitalAdapter;
import com.cmcc.aregister.ui.adapter.ChoiceOtherSchAdapter;
import com.cmcc.aregister.ui.adapter.ChoiceTimeAdapter;
import com.cmcc.aregister.ui.adapter.ChoiceTiptypeAdapter;
import com.cmcc.aregister.ui.adapter.TextAdapter;
import com.cmcc.aregister.ui.dialog.DepartmentInfoDialog;
import com.cmcc.aregister.ui.dialog.DoctorInfoDialog;
import com.cmcc.aregister.ui.dialog.HospitalInfoDialog;

/**
 * 选择预约
 * @author ld
 * 
 */
public class ChoiceActivity extends ParentActivity implements
    DataCallback_other
{
    private static final String TAG = "ChoiceActivity";
    // ------view------
    private LinearLayout two_top_hearder_choice, other_header_choice_doctor,
        zhuanjiaLayout, putongLayout, searchLayout;
    private TextView right_btn, left_btn, top_left_btn, by_time, by_doctor,
        putong_txt, zhuanjia_txt;
    private TextView putong_bg, zhuanjia_bg;
    private EditText search_editText;
    // private Gallery gallery;
    private GridView grid;
    private ListView listview;
    private LinearLayout no_data_layout;
    private RelativeLayout ly_right_btn, ly_left_btn;
    // ------parameter------
    private int currentTitleSelect = -1;
    private int choice_type;
    private int area_type_int;
    private String area_type_str;
    private int title;
    private ImageView title_bg, search_img_button;
    private Button search_btn;
    private List<AreaModel> areaList = new ArrayList<AreaModel>();
    private List<HospitalModel> hospitalList = new ArrayList<HospitalModel>();
    private List<DepModel> depList = new ArrayList<DepModel>();
    private List<DocModel> docList_common = new ArrayList<DocModel>();
    private List<DocModel> docList_profession = new ArrayList<DocModel>();
    private List<ScheduleModel> schList = new ArrayList<ScheduleModel>();
    @SuppressLint("UseSparseArrays")
    private Map<Integer, List<Hospital>> hospitalMap = new HashMap<Integer, List<Hospital>>();
    // private List<Hospital> hospitalList = new ArrayList<Hospital>();
    private List<Doctor> doctorList = new ArrayList<Doctor>();
    private List<Department> departmentList = new ArrayList<Department>();
    private List<Schedule> scheduleList = new ArrayList<Schedule>();
    private int allPage;
    private int currPage;
    private int currPage_c = 1;
    private int currPage_p = 1;
    private String[] local_address_number;
    private String[] province_address_number;
    private int currentSelectPosition = -1;
    private String area_id = "";// 异地城市id
    private String unit_id = ""; // 医院id
    private String dep_id = ""; // 科室id
    private String doc_id = "";// 医生id
    private String schedule_id = ""; // 出诊id
    private String schedule_info = ""; // 出诊信息
    private Department department;
    private Doctor doctor;
    private boolean isLocal;
    private Hospital hospital;
    private int grid_layout_width_local;
    private int grid_layout_width_other;
    private int grid_layout_height;
    private FamilyModel family;
    private boolean searchHospital = false;

    // -----------
    private ChoiceAreaAdapter choiceAreaAdapter;
    private ChoiceOtherHospitalAdapter choiceOtherHospitalAdapter;
    private ChoiceOtherDepAdapter choiceOtherDepAdapter;
    private ChoiceOtherDocAdapter choiceOtherDocAdapter_common;
    private ChoiceOtherDocAdapter choiceOtherDocAdapter_profession;
    private ChoiceOtherSchAdapter choiceOtherSchAdapter;

    private ChoiceHospitalAdapter choiceHospitalAdapter;
    private ChoiceDepartmentAdapter choiceDepartmentAdapter;
    private ChoiceDoctorAdapter choiceDoctorAdapter;
    private ChoiceTimeAdapter choiceTimeAdapter;
    private ChoiceTiptypeAdapter choiceTiptypeAdapter;
    private List<Map<Integer, String>> tipTypelist = new ArrayList<Map<Integer, String>>();
    private TextAdapter galleryAdapter = null;
    private View currentSelectGalleryView;
    private String isHaoyuanTip = "";
    private String isAutoAppointment = "";
    private int outType = 0;
    int doc_totalcount_c, doc_totalcount_p;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        Intent intent = getIntent();
        isHaoyuanTip = intent.getStringExtra("isHaoyuanTip");
        isAutoAppointment = intent.getStringExtra("isAutoAppointment");
        init(R.layout.p_choice);
    }

    private void clearArg()
    {
        area_id = "";// 异地城市id
        unit_id = ""; // 医院id
        dep_id = ""; // 科室id
        doc_id = "";// 医生id
        schedule_id = ""; // 出诊id
    }

    @Override
    protected void setupData()
    {
        clearArg();
        title_bg = (ImageView) findViewById(R.id.title);
        Map<String, Object> httpMap = ((PotoalParcelable) getIntent()
            .getParcelableExtra(Arguments.INTENT_TO_NEXT_PAGE)).map;
        choice_type = (Integer) httpMap
            .get(Arguments.ACTIVITY_JUMP_CHOICE_TYPE);// 是否选择城市、医院、科室、医生等
        if (httpMap.containsKey(Arguments.ACTIVITY_JUMP_OTHER_AREAR_ID))
        {
            area_id = (String) httpMap
                .get(Arguments.ACTIVITY_JUMP_OTHER_AREAR_ID);
        }
        if (httpMap.containsKey(Arguments.ACTIVITY_JUMP_UNIT_ID))
        {
            unit_id = (String) httpMap.get(Arguments.ACTIVITY_JUMP_UNIT_ID);
        }
        if (httpMap.containsKey(Arguments.ACTIVITY_JUMP_DEP_ID))
        {
            dep_id = (String) httpMap.get(Arguments.ACTIVITY_JUMP_DEP_ID);
        }
        if (httpMap.containsKey(Arguments.ACTIVITY_JUMP_DOCTOR_ID))
        {
            doc_id = (String) httpMap.get(Arguments.ACTIVITY_JUMP_DOCTOR_ID);
        }
        if (httpMap.containsKey(Arguments.ACTIVITY_JUMP_SCHEDULE_ID))
        {
            schedule_id = (String) httpMap
                .get(Arguments.ACTIVITY_JUMP_SCHEDULE_ID);
        }
        if (httpMap.containsKey(Arguments.ACTIVITY_JUMP_CHOICE_DOCTOR))
        {
            schedule_info = (String) httpMap
                .get(Arguments.ACTIVITY_JUMP_CHOICE_DOCTOR);
        }
        area_type_int = (Integer) httpMap
            .get(Arguments.ACTIVITY_JUMP_AREA_TYPE);// 本地还是异地
        if (area_type_int == R.id.left_btn)
        {// 如果是本地
            switch (choice_type)
            {
            case 0:
                // title = R.string.choice_hospital;
                title_bg.setBackgroundResource(R.drawable.choice_hospital);
                search_btn = (Button) findViewById(R.id.top_search_btn);
                search_btn.setOnClickListener(onClickListener);
                search_btn.setVisibility(View.VISIBLE);
                search_img_button = (ImageView) findViewById(R.id.search_btn_imgView);
                search_img_button.setOnClickListener(onClickListener);
                for (int i = 0; i < 9; i++)
                {// 本地固定好的区域，写在本地
                    hospitalMap.put(i, new ArrayList<Hospital>());
                }
                break;
            case 1:
                title_bg.setBackgroundResource(R.drawable.choice_dept);
                break;
            case 2:
                // title = R.string.choice_doctor;
                title_bg.setBackgroundResource(R.drawable.choice_doctor);
                break;
            case 3:
                if (isHaoyuanTip != null && isHaoyuanTip.equals("yes"))
                {
                    title = R.string.choice_tiptype;
                }
                else
                {
                    // title = R.string.choice_time;
                    title_bg.setBackgroundResource(R.drawable.choice_time);
                }
                break;
            }
        }
        else
        {
            switch (choice_type)
            {
            case 0:
                // title = R.string.choice_city;
                title_bg.setBackgroundResource(R.drawable.choice_area);
                for (int i = 0; i < 9; i++)
                {// 本地固定好的区域，写在本地
                    hospitalMap.put(i, new ArrayList<Hospital>());
                }
                break;
            case 1:
                // title = R.string.choice_hospital;
                title_bg.setBackgroundResource(R.drawable.choice_hospital);
                break;
            case 2:
                // title = R.string.choice_subject;
                title_bg.setBackgroundResource(R.drawable.choice_dept);
                break;
            case 3:
                // title = R.string.choice_doctor;
                title_bg.setBackgroundResource(R.drawable.choice_doctor);
                break;
            case 4:
                // title = R.string.choice_time;
                title_bg.setBackgroundResource(R.drawable.choice_time);
                break;
            }
        }
        local_address_number = getResources().getStringArray(
            R.array.local_address_number);
        province_address_number = getResources().getStringArray(
            R.array.province_address_number);
        grid_layout_width_local = getResources().getDimensionPixelOffset(
            R.dimen.grid_layout_width_local);
        grid_layout_width_other = getResources().getDimensionPixelOffset(
            R.dimen.grid_layout_width_other);
        grid_layout_height = getResources().getDimensionPixelOffset(
            R.dimen.grid_layout_height);

    }

    private boolean isInit = false;// 初次加载医生列表（异地）
    private TextView no_data_txt;

    @Override
    protected void setupView()
    {
        top_left_btn = (TextView) findViewById(R.id.top_left_btn);
        other_header_choice_doctor = (LinearLayout) findViewById(R.id.other_header_choice_doctor);
        two_top_hearder_choice = (LinearLayout) findViewById(R.id.two_top_hearder_choice);
        searchLayout = (LinearLayout) findViewById(R.id.search_layout);
        // gallery = (Gallery) findViewById(R.id.gallery);
        grid = (GridView) findViewById(R.id.grid);
        listview = (ListView) findViewById(R.id.listview);
        no_data_layout = (LinearLayout) findViewById(R.id.no_data_layout);
        no_data_txt = (TextView) findViewById(R.id.no_data_txt);
        top_left_btn.setText(R.string.cancel);
        top_left_btn.setVisibility(View.VISIBLE);
        top_left_btn.setOnClickListener(onClickListener);
        listview.setOnItemClickListener(onItemClickListener);
        search_editText = (EditText) findViewById(R.id.search_content);
        switch (area_type_int)
        {
        case R.id.left_btn:
            ((LinearLayout) findViewById(R.id.grid_layout))
                .setLayoutParams(new LayoutParams(grid_layout_width_local,
                    grid_layout_height));
            galleryAdapter = new TextAdapter(context,
                R.array.local_address_name, R.color.gray);
            area_type_str = "0";
            isLocal = true;
            break;
        case R.id.center_btn:
            ((LinearLayout) findViewById(R.id.grid_layout))
                .setLayoutParams(new LayoutParams(grid_layout_width_other,
                    grid_layout_height));
            galleryAdapter = new TextAdapter(context,
                R.array.province_address_name, R.color.gray);
            grid.setVisibility(View.GONE);
            area_type_str = "1";
            isLocal = false;
            break;
        }
        switch (choice_type)
        {
        case 0:// 第一项（本地为医院，异地为城市）
            findViewById(R.id.scroll_view).setVisibility(View.VISIBLE);
            grid.setVisibility(View.VISIBLE);
            grid.setNumColumns(galleryAdapter.getCount());
            galleryAdapter.select = 0;
            grid.setSelector(new ColorDrawable(Color.TRANSPARENT));
            grid.setAdapter(galleryAdapter);
            grid.setOnItemClickListener(onItemClickListener2);
            currentSelectPosition = 0;
            if (isLocal)
            {
                sendSearchHospitalTask(area_type_str, local_address_number[0],
                    "", "", "1", HttpAsyncTask.CACHE_TYPE_SAVE);
            }
            else
            {
                findViewById(R.id.scroll_view).setVisibility(View.GONE);
                currPage += 1;
                showProgressDialog();
                sendSearchAreaListTask(currPage);
            }
            break;
        case 1:// 第二项（本地为科室，异地为医院）
            if (isLocal)
            {
                sendGetDepartmentListTask(area_type_str,
                    ConfigUtilHelper.getMobile(app), unit_id, "", "1",
                    HttpAsyncTask.CACHE_TYPE_SAVE);
            }
            else
            {
                currPage += 1;
                showProgressDialog();
                sendSearchHospitalListTask(currPage);
            }
            break;
        case 2:// 第三项（本地为医生，异地为科室）
            if (isLocal)
            {
                two_top_hearder_choice.setVisibility(View.VISIBLE);
                ly_left_btn = (RelativeLayout) findViewById(R.id.ly_left_btn);
                ly_right_btn = (RelativeLayout) findViewById(R.id.ly_right_btn);
                by_doctor = (TextView) findViewById(R.id.by_doctor);
                by_time = (TextView) findViewById(R.id.by_time);
                ly_left_btn.setOnClickListener(onClickListener);
                ly_right_btn.setOnClickListener(onClickListener);
                check(R.id.ly_left_btn, false);
                sendGetDoctorListTask(area_type_str,
                    ConfigUtilHelper.getMobile(app), unit_id, dep_id, "", "1",
                    HttpAsyncTask.CACHE_TYPE_SAVE);
            }
            else
            {
                currPage += 1;
                showProgressDialog();
                sendSearchDepListTask(currPage);
            }
            break;
        case 3:// 第四项（本地为班次，异地为医生）
            if (isLocal)
            {
                sendGetScheduleListTask(unit_id, schedule_id);
            }
            else
            {
                // two_top_hearder.setVisibility(View.VISIBLE);
                other_header_choice_doctor.setVisibility(View.VISIBLE);
                zhuanjiaLayout = (LinearLayout) findViewById(R.id.zhuanjiaLayout);
                putongLayout = (LinearLayout) findViewById(R.id.putongLayout);
                zhuanjia_bg = (TextView) findViewById(R.id.zhuanjia_bg);
                zhuanjia_txt = (TextView) findViewById(R.id.zhuanjia_txt);
                putong_bg = (TextView) findViewById(R.id.putong_bg);
                putong_txt = (TextView) findViewById(R.id.putong_txt);
                zhuanjiaLayout.setOnClickListener(onClickListener);
                putongLayout.setOnClickListener(onClickListener);
                currPage_c += 1;
                showProgressDialog();
                outType = 1;// 默认是专家号源
                isInit = true;
                sendSearchDocListTask(currPage_c, outType);
            }
            break;
        case 4:// 第五项（本地为人员，异地为班次）
            if (isLocal)
            {
                sendGetScheduleListTask(unit_id, schedule_id);
                // getFamily();
            }
            else
            {
                currPage += 1;
                showProgressDialog();
                sendSearchSchListTask(0);
            }
            break;
        }

    }

    OnItemClickListener onItemClickListener2 = new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int position,
            long arg3)
        {
            if (currentSelectPosition == position)
            {
                return;
            }
            else
            {
                // flushGalleryView(view, position);
                galleryAdapter.select = position;
                galleryAdapter.notifyDataSetChanged();
                currentSelectPosition = position;
                // listview.setAdapter(null);
                if ("0".equals(area_type_str))
                {
                    sendSearchHospitalTask(area_type_str,
                        local_address_number[position], "", "", "1",
                        HttpAsyncTask.CACHE_TYPE_SAVE);
                }
                else
                {
                    sendSearchHospitalTask(area_type_str,
                        province_address_number[position], "", "", "1",
                        HttpAsyncTask.CACHE_TYPE_SAVE);
                }
            }
        }

    };

    private void flushGalleryView(View view, int position)
    {
        logger.e("---------------flushGalleryView-----------");
        if (view != null)
        {
            if (!view.equals(currentSelectGalleryView))
            {
                if (currentSelectGalleryView != null)
                {
                    currentSelectGalleryView
                        .setBackgroundResource(R.drawable.top_three_text_u);
                }
                else
                {
                    grid.getChildAt(0).setBackgroundResource(
                        R.drawable.top_three_text_u);
                }
                view.setBackgroundResource(R.drawable.top_three_text_s);
                currentSelectGalleryView = view;
            }
        }
        else
        {
            if (position == 0)
            {
                View v = grid.getChildAt(0);
                if (v != null)
                {
                    logger.d("-----position 0 is not null----");
                    if (currentSelectGalleryView != null)
                    {
                        currentSelectGalleryView
                            .setBackgroundResource(R.drawable.top_three_text_u);
                    }
                    v.setBackgroundResource(R.drawable.top_three_text_s);
                    currentSelectGalleryView = v;
                }
            }
        }
    }

    public void setView()
    {
        switch (choice_type)
        {
        case 0:
            if (hospitalMap.get(currentSelectPosition) != null)
            {
                if (hospitalMap.get(currentSelectPosition).size() > 0)
                {
                    if (choiceHospitalAdapter == null)
                    {
                        choiceHospitalAdapter = new ChoiceHospitalAdapter(
                            context, hospitalMap.get(currentSelectPosition),
                            currPage, allPage, handler, isLocal);
                        listview.setAdapter(choiceHospitalAdapter);
                    }
                    else
                    {
                        choiceHospitalAdapter.list = hospitalMap
                            .get(currentSelectPosition);
                        choiceHospitalAdapter.currPage = currPage;
                        choiceHospitalAdapter.allPage = allPage;
                        choiceHospitalAdapter.notifyDataSetChanged();
                        // listview.setAdapter(choiceHospitalAdapter);
                    }
                    showNoData(false);
                }
                else
                {
                    showNoData(true);
                }
            }
            break;
        case 1:
            if (departmentList.size() > 0)
            {
                if (choiceDepartmentAdapter == null)
                {
                    choiceDepartmentAdapter = new ChoiceDepartmentAdapter(
                        context, departmentList, currPage, allPage, handler,
                        isLocal);
                    listview.setAdapter(choiceDepartmentAdapter);
                }
                else
                {
                    choiceDepartmentAdapter.list = departmentList;
                    choiceDepartmentAdapter.currPage = currPage;
                    choiceDepartmentAdapter.allPage = allPage;
                    choiceDepartmentAdapter.notifyDataSetChanged();
                    // listview.setAdapter(choiceDepartmentAdapter);
                }
                showNoData(false);
            }
            else
            {
                showNoData(true);
            }
            break;
        case 2:
            if (doctorList.size() > 0)
            {
                if (choiceDoctorAdapter == null)
                {
                    choiceDoctorAdapter = new ChoiceDoctorAdapter(context,
                        doctorList, allPage, handler, currPage, isLocal);
                    listview.setAdapter(choiceDoctorAdapter);
                }
                else
                {
                    choiceDoctorAdapter.setDate(doctorList, isLocal);
                    choiceDoctorAdapter.allPage = allPage;
                    choiceDoctorAdapter.currPage = currPage;
                    if (isLocal)
                    {
                        if (currentTitleSelect == R.id.left_btn)
                        {
                            choiceDoctorAdapter.sequenceDate(true);
                        }
                        else
                        {
                            choiceDoctorAdapter.sequenceDate(false);
                        }
                    }
                    choiceDoctorAdapter.notifyDataSetChanged();
                    // listview.setAdapter(choiceDoctorAdapter);
                }
                showNoData(false);
            }
            else
            {
                no_data_txt.setText(R.string.no_sch_data_text);
                showNoData(true);
            }
            break;
        case 3:
            if (isHaoyuanTip != null && isHaoyuanTip.equals("yes"))
            {
                Map<Integer, String> map1 = new HashMap<Integer, String>();
                map1.put(1,
                    getResources().getString(R.string.haoyuan_tip_type_1));

                Map<Integer, String> map2 = new HashMap<Integer, String>();
                map2.put(2,
                    getResources().getString(R.string.haoyuan_tip_type_2));
                tipTypelist.add(map1);
                tipTypelist.add(map2);
                if (choiceTiptypeAdapter == null)
                {
                    choiceTiptypeAdapter = new ChoiceTiptypeAdapter(context,
                        tipTypelist);
                    listview.setAdapter(choiceTiptypeAdapter);
                }
            }
            else
            {
                if (scheduleList.size() > 0)
                {
                    if (choiceTimeAdapter == null)
                    {
                        choiceTimeAdapter = new ChoiceTimeAdapter(context,
                            scheduleList, schedule_info);
                        listview.setAdapter(choiceTimeAdapter);
                    }
                    else
                    {
                        choiceTimeAdapter.list = scheduleList;
                        choiceTimeAdapter.notifyDataSetChanged();
                    }
                    showNoData(false);
                }
                else
                {
                    no_data_txt.setText(R.string.no_sch_data_text);
                    showNoData(true);
                }
            }
            break;
        }
    }

    /**
     * 是否显示无数据图片
     * 
     * @param flag
     */
    public void showNoData(boolean flag)
    {
        if (flag)
        {
            listview.setVisibility(View.GONE);
            no_data_layout.setVisibility(View.VISIBLE);
        }
        else
        {
            listview.setVisibility(View.VISIBLE);
            no_data_layout.setVisibility(View.GONE);
        }
    }

    OnItemClickListener onItemClickListener = new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position,
            long arg3)
        {
            if (area_type_int == R.id.left_btn)
            {
                localReturn(position);
            }
            else
            {
                otherReturn(position);
            }
        }
    };

    /**
     * 点击list每项的处理（异地）
     * @param position
     */
    private void otherReturn(int position)
    {
        HashMap<String, Object> map = new HashMap<String, Object>();
        switch (choice_type)
        {
        case 0:// 选择地域
            map.put(Arguments.ACTIVITY_JUMP_OTHER_AREAR_NAME,
                areaList.get(position).areaname);
            map.put(Arguments.ACTIVITY_JUMP_OTHER_PRO_NAME,
                areaList.get(position).province);
            map.put(Arguments.ACTIVITY_JUMP_OTHER_AREAR_ID,
                areaList.get(position).areaid);
            break;
        case 1:// 选择医院
            map.put(Arguments.ACTIVITY_JUMP_CHOICE_HOSPITAL,
                hospitalList.get(position).hospitalname);
            map.put(Arguments.ACTIVITY_JUMP_UNIT_ID,
                hospitalList.get(position).hospitalid);
            break;
        case 2:// 选择科室
            map.put(Arguments.ACTIVITY_JUMP_CHOICE_DEPARTMENT,
                depList.get(position).deptname);
            map.put(Arguments.ACTIVITY_JUMP_DEP_ID,
                depList.get(position).deptid);
            break;
        case 3:// 选择医生
            if (outType == 0)
            {// 普通
                map.put(Arguments.ACTIVITY_JUMP_CHOICE_DOCTOR_TYPE, "0");
                map.put(Arguments.ACTIVITY_JUMP_CHOICE_DOCTOR,
                    docList_common.get(position).doctorname);
                map.put(Arguments.ACTIVITY_JUMP_DOCTOR_ID,
                    docList_common.get(position).doctorId);
                map.put(Arguments.ACTIVITY_JUMP_GUAHAO_AMT,
                    docList_common.get(position).outType);
            }
            else
            {// 专家
                map.put(Arguments.ACTIVITY_JUMP_CHOICE_DOCTOR_TYPE, "1");
                map.put(Arguments.ACTIVITY_JUMP_CHOICE_DOCTOR,
                    docList_profession.get(position).doctorname);
                map.put(Arguments.ACTIVITY_JUMP_DOCTOR_ID,
                    docList_profession.get(position).doctorId);
                map.put(Arguments.ACTIVITY_JUMP_GUAHAO_AMT,
                    docList_profession.get(position).outType);
            }
            break;
        case 4:
            if (position < (schList.size()))
            {
                if (schList.get(position).number <= 0)
                {
                    showSingleAlertDlg(getString(R.string.notice),
                        getString(R.string.no_left_num),
                        getString(R.string.close));
                    return;
                }
                map.put(
                    Arguments.ACTIVITY_JUMP_OTHER_SCH_CONTENT,
                    schList.get(position).healDate + " "
                        + schList.get(position).weekDay + " "
                        + schList.get(position).dayTime);
                map.put(Arguments.ACTIVITY_JUMP_OTHER_SCH_ID,
                    schList.get(position).recordId);
            }
            else
            {
                map.put(Arguments.ACTIVITY_JUMP_OTHER_SCH_CONTENT,
                    getString(R.string.kefu_sch));
                map.put(Arguments.ACTIVITY_JUMP_OTHER_SCH_ID, 0);
            }
            break;
        }
        map.put(Arguments.ACTIVITY_JUMP_SCREENING_TYPE, choice_type);
        Intent intent = getIntent();
        PotoalParcelable potoal = new PotoalParcelable(map);
        intent.putExtra(Arguments.INTENT_TO_NEXT_PAGE, potoal);
        setResult(RESULT_OK, getIntent());
        finish();
    }

    /**
     * 点击list每项的处理（本地）
     * @param position
     */
    private void localReturn(int position)
    {
        HashMap<String, Object> map = new HashMap<String, Object>();
        switch (choice_type)
        {
        case 0:
            Hospital hospital = hospitalMap.get(currentSelectPosition).get(
                position);
            if ((isHaoyuanTip != null && isHaoyuanTip.equals("yes"))
                || (isAutoAppointment != null && isAutoAppointment
                    .equals("yes")))
            {
                map.put(Arguments.ACTIVITY_JUMP_CHOICE_HOSPITAL,
                    hospital.unit_name);
                map.put(Arguments.ACTIVITY_JUMP_UNIT_ID, hospital.unit_id);
            }
            else
            {
                if (isLocal && hospital.left_num.equals("0"))
                {
                    showSingleAlertDlg(getString(R.string.notice),
                        getString(R.string.no_left_num),
                        getString(R.string.close));
                    return;
                }
                else
                {
                    map.put(Arguments.ACTIVITY_JUMP_CHOICE_HOSPITAL,
                        hospital.unit_name);
                    map.put(Arguments.ACTIVITY_JUMP_UNIT_ID, hospital.unit_id);
                }
            }
            map.put(Arguments.ACTIVITY_JUMP_SCREENING_TYPE, choice_type);
            Intent intent = getIntent();
            PotoalParcelable potoal = new PotoalParcelable(map);
            intent.putExtra(Arguments.INTENT_TO_NEXT_PAGE, potoal);
            setResult(RESULT_OK, getIntent());
            finish();
            break;
        case 1:
            Department department = departmentList.get(position);
            if ((isHaoyuanTip != null && isHaoyuanTip.equals("yes"))
                || (isAutoAppointment != null && isAutoAppointment
                    .equals("yes")))
            {
                map.put(Arguments.ACTIVITY_JUMP_CHOICE_DEPARTMENT,
                    department.dep_name);
                map.put(Arguments.ACTIVITY_JUMP_CHOICE_HOSPITAL,
                    department.unit_name);
                map.put(Arguments.ACTIVITY_JUMP_UNIT_ID, department.unit_id);
                map.put(Arguments.ACTIVITY_JUMP_DEP_ID, department.dep_id);
            }
            else
            {
                if (isLocal && department.left_num.equals("0"))
                {
                    showSingleAlertDlg(getString(R.string.notice),
                        getString(R.string.no_left_num),
                        getString(R.string.close));
                    return;
                }
                else
                {
                    map.put(Arguments.ACTIVITY_JUMP_CHOICE_DEPARTMENT,
                        department.dep_name);
                    map.put(Arguments.ACTIVITY_JUMP_CHOICE_HOSPITAL,
                        department.unit_name);
                    map.put(Arguments.ACTIVITY_JUMP_UNIT_ID, department.unit_id);
                    map.put(Arguments.ACTIVITY_JUMP_DEP_ID, department.dep_id);
                }
            }
            map.put(Arguments.ACTIVITY_JUMP_SCREENING_TYPE, choice_type);
            Intent intent1 = getIntent();
            PotoalParcelable potoal1 = new PotoalParcelable(map);
            intent1.putExtra(Arguments.INTENT_TO_NEXT_PAGE, potoal1);
            // 儿童医院、遗传代谢科、生酮饮食科预约提醒 111是儿童医院的ID,3887表示遗传代谢科 6546代表生酮饮食科
            if (unit_id.equals("111"))
            {
                if (department.dep_id.equals("3887"))
                {
                    showAlertTipDlg(getString(R.string.notice),
                        getString(R.string.yichuan_tip),
                        getString(R.string.confirm), getString(R.string.cancel));
                }
                else if (department.dep_id.equals("6546"))
                {
                    showAlertTipDlg(getString(R.string.notice),
                        getString(R.string.shengtong_tip),
                        getString(R.string.confirm), getString(R.string.cancel));
                }
                else
                {
                    setResult(RESULT_OK, getIntent());
                    finish();
                }
            }
            else
            {
                setResult(RESULT_OK, getIntent());
                finish();
            }
            break;
        case 2:
            Doctor doctor;
            if (isLocal)
            {
                Schedule sch = choiceDoctorAdapter.schList.get(position);
                if (sch.left_num.equals("0"))
                {
                    if (isHaoyuanTip == "" && isAutoAppointment == "")
                    {
                        showSingleAlertDlg(getString(R.string.notice),
                            getString(R.string.no_left_num),
                            getString(R.string.close));
                        return;
                    }
                }
                doctor = sch.doctor;
                map.put(Arguments.ACTIVITY_JUMP_CHOICE_DOCTOR,
                    doctor.doctor_name + " " + sch.to_date + " "
                        + sch.time_type);
                map.put(Arguments.ACTIVITY_JUMP_SCHEDULE_ID, sch.schedule_id);
                map.put(Arguments.ACTIVITY_JUMP_DOCTOR_ID, doctor.doctor_id);
            }
            else
            {
                doctor = doctorList.get(position);
                map.put(Arguments.ACTIVITY_JUMP_CHOICE_DOCTOR,
                    doctor.doctor_name);
                map.put(Arguments.ACTIVITY_JUMP_DOCTOR_ID, doctor.doctor_id);
            }
            map.put(Arguments.ACTIVITY_JUMP_CHOICE_DEPARTMENT, doctor.dep_name);
            map.put(Arguments.ACTIVITY_JUMP_CHOICE_HOSPITAL, doctor.unit_name);
            map.put(Arguments.ACTIVITY_JUMP_UNIT_ID, doctor.unit_id);
            map.put(Arguments.ACTIVITY_JUMP_DEP_ID, doctor.dep_id);
            map.put(Arguments.ACTIVITY_JUMP_GUAHAO_AMT, doctor.guahao_amt);
            map.put(Arguments.ACTIVITY_JUMP_SCREENING_TYPE, choice_type);
            Intent intent2 = getIntent();
            PotoalParcelable potoal2 = new PotoalParcelable(map);
            intent2.putExtra(Arguments.INTENT_TO_NEXT_PAGE, potoal2);
            setResult(RESULT_OK, getIntent());
            finish();
            break;
        case 3:
            if (isHaoyuanTip != null && isHaoyuanTip.equals("yes"))
            {
                Map<Integer, String> typeMap = tipTypelist.get(position);
                map.put(Arguments.ACTIVITY_JUMP_CHOICE_TIPTYPE_VALUE,
                    typeMap.get(position + 1));
                map.put(Arguments.ACTIVITY_JUMP_CHOICE_TIPTYPE, position + 1);
            }
            else
            {
                Schedule schedule = scheduleList.get(position);
                if (schedule.left_num.equals("0"))
                {
                    if (isHaoyuanTip == "" && isAutoAppointment == "")
                    {
                        showSingleAlertDlg(getString(R.string.notice),
                            getString(R.string.no_left_num),
                            getString(R.string.close));
                        return;
                    }
                }
                map.put(Arguments.ACTIVITY_JUMP_CHOICE_TIME,
                    schedule.begin_time + " - " + schedule.end_time);
                map.put(Arguments.ACTIVITY_JUMP_DETL_ID, schedule.detl_id);
            }
            map.put(Arguments.ACTIVITY_JUMP_SCREENING_TYPE, choice_type);
            Intent intent3 = getIntent();
            PotoalParcelable potoal3 = new PotoalParcelable(map);
            intent3.putExtra(Arguments.INTENT_TO_NEXT_PAGE, potoal3);
            setResult(RESULT_OK, getIntent());
            finish();
            break;
        }

    }

    public void showAlertTipDlg(String title, String msg, String posTitle,
        String nagativeTitle)
    {
        new AlertDialog.Builder(this)
            .setTitle(title)
            .setMessage(msg)
            .setIcon(android.R.drawable.ic_dialog_info)
            .setCancelable(true)
            .setPositiveButton(posTitle, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which)
                {
                    setResult(RESULT_OK, getIntent());
                    finish();
                }
            })
            .setNegativeButton(nagativeTitle,
                new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which)
                    {

                    }
                }).create().show();
    }

    OnClickListener onClickListener = new OnClickListener() {
        @Override
        public void onClick(View v)
        {
            int id = v.getId();
            if (id == R.id.top_left_btn)
            {
                finish();
                return;
            }
            if (isLocal)
            {// 本地
                if (id == R.id.ly_left_btn || id == R.id.ly_right_btn)
                {
                    check(id, true);
                }
                if (id == R.id.top_search_btn)
                {
                    searchHospital = true;
                    findViewById(R.id.scroll_view).setVisibility(View.GONE);
                    searchLayout.setVisibility(View.VISIBLE);
                }
                if (id == R.id.search_btn_imgView)
                {
                    sendSearchHospitalTask(area_type_str,
                        local_address_number[0], "", search_editText.getText()
                            .toString(), "1", HttpAsyncTask.CACHE_TYPE_SAVE);
                }
            }
            else
            {// 异地
                if (id == R.id.putongLayout)
                { // 普通门诊
                    if (outType != 0)
                    {
                        outType = 0;
                        zhuanjia_bg.setBackgroundResource(R.drawable.zhuanjia);
                        putong_bg
                            .setBackgroundResource(R.drawable.putong_press);
                        zhuanjia_txt.setTextColor(getResources().getColor(
                            R.color.gray));
                        putong_txt.setTextColor(getResources().getColor(
                            R.color.sky_blue));
                        // choiceOtherDocAdapter_profession = null;
                        if (docList_common.size() == 0)
                        {
                            currPage_c = 1;
                            showProgressDialog();
                            sendSearchDocListTask(currPage_c, outType);
                        }
                        else
                        {
                            boolean isEnd = true;
                            if (currPage_c
                                * Integer.parseInt(Arguments.pageSize) < doc_totalcount_c)
                            {
                                isEnd = false;
                            }
                            else
                            {
                                isEnd = true;
                            }
                            showNoData(false);
                            choiceOtherDocAdapter_common = new ChoiceOtherDocAdapter(
                                ChoiceActivity.this, docList_common, isEnd,
                                ChoiceActivity.this);
                            listview.setAdapter(choiceOtherDocAdapter_common);
                        }
                    }
                }
                else if (id == R.id.zhuanjiaLayout)
                { // 点击普通门诊按钮
                  // showInfoDialog(getString(R.string.yidi_huajia_nouse),
                  // true);
                  // return;
                    if (outType != 1)
                    {// 暂时屏蔽专家门诊
                        outType = 1;
                        zhuanjia_bg
                            .setBackgroundResource(R.drawable.zhuanjia_press);
                        putong_bg.setBackgroundResource(R.drawable.putong);
                        zhuanjia_txt.setTextColor(getResources().getColor(
                            R.color.sky_blue));
                        putong_txt.setTextColor(getResources().getColor(
                            R.color.gray));
                        if (docList_profession.size() == 0)
                        {
                            currPage_p = 1;
                            showProgressDialog();
                            sendSearchDocListTask(currPage_p, outType);
                        }
                        else
                        {
                            boolean isEnd = true;
                            if (currPage_p
                                * Integer.parseInt(Arguments.pageSize) < doc_totalcount_p)
                            {
                                isEnd = false;
                            }
                            else
                            {
                                isEnd = true;
                            }
                            showNoData(false);
                            choiceOtherDocAdapter_profession = new ChoiceOtherDocAdapter(
                                ChoiceActivity.this, docList_profession, isEnd,
                                ChoiceActivity.this);
                            listview
                                .setAdapter(choiceOtherDocAdapter_profession);
                        }
                    }
                }
            }
        }
    };

    public void check(int id, boolean hasAnimation)
    {
        if (currentTitleSelect == id)
        {
            return;
        }
        if (currentTitleSelect > 0)
        {
            findViewById(currentTitleSelect).setSelected(false);
        }
        currentTitleSelect = id;
        findViewById(currentTitleSelect).setSelected(true);
        if (hasAnimation)
        {
            if (choiceDoctorAdapter != null)
            {
                switch (currentTitleSelect)
                {
                case R.id.ly_right_btn:
                    choiceDoctorAdapter.sequenceDate(true);
                    by_doctor.setBackgroundResource(R.drawable.by_doctor);
                    by_time.setBackgroundResource(R.drawable.by_time_press);
                    break;
                case R.id.ly_left_btn:
                    choiceDoctorAdapter.sequenceDate(false);
                    by_doctor.setBackgroundResource(R.drawable.by_doctor_press);
                    by_time.setBackgroundResource(R.drawable.by_time);
                    break;
                }
                start3DAnimation(listview);
            }
            if (sendGetDoctorListTask != null)
            {
                sendGetDoctorListTask.setTaskBindingHandler(null);
            }
        }

    }

    @Override
    public void animFrushView()
    {
        if (choiceDoctorAdapter != null && choiceDoctorAdapter.getCount() > 0)
        {
            choiceDoctorAdapter.notifyDataSetChanged();
            showNoData(false);
        }
        else
        {
            showNoData(true);
        }
    }

    private void showHospitalInfoDialog(Hospital hospital)
    {
        dialog = new HospitalInfoDialog(this, hospital);
        if (dialog != null)
        {
            dialog.show();
        }
    }

    private void showDepartmentInfoDialog(Department department)
    {
        dialog = new DepartmentInfoDialog(this, department);
        if (dialog != null)
        {
            dialog.show();
        }
    }

    private void showDoctorInfoDialog(Doctor doctor)
    {
        dialog = new DoctorInfoDialog(this, doctor);
        if (dialog != null)
        {
            dialog.show();
        }
    }

    Handler handler = new Handler() {

        @Override
        public void handleMessage(Message msg)
        {
            int position = (Integer) msg.obj;
            switch (msg.what)
            {
            case -1:
                switch (choice_type)
                {
                case 0:
                    if (searchHospital)
                    {
                        sendSearchHospitalTask(area_type_str, "", "",
                            search_editText.getText().toString(), currPage + 1
                                + "", HttpAsyncTask.CACHE_TYPE_ACTION);
                    }
                    else
                    {
                        if ("0".equals(area_type_str))
                        {
                            sendSearchHospitalTask(area_type_str,
                                local_address_number[currentSelectPosition],
                                "", "", currPage + 1 + "",
                                HttpAsyncTask.CACHE_TYPE_ACTION);
                        }
                        else
                        {
                            sendSearchHospitalTask(area_type_str,
                                province_address_number[currentSelectPosition],
                                "", "", currPage + 1 + "",
                                HttpAsyncTask.CACHE_TYPE_ACTION);
                        }
                    }
                    break;
                case 1:
                    sendGetDepartmentListTask(area_type_str,
                        ConfigUtilHelper.getMobile(app), unit_id, "", currPage
                            + 1 + "", HttpAsyncTask.CACHE_TYPE_ACTION);
                    break;
                case 2:
                    sendGetDoctorListTask(area_type_str,
                        ConfigUtilHelper.getMobile(app), unit_id, dep_id, "",
                        currPage + 1 + "", HttpAsyncTask.CACHE_TYPE_ACTION);
                    break;
                case 3:
                    break;
                }
                break;
            case 0:
                hospital = hospitalMap.get(currentSelectPosition).get(position);
                sendGetHospitalDetailTask(ConfigUtilHelper.getMobile(app),
                    area_type_str, hospital.unit_id);
                break;
            case 1:
                department = departmentList.get(position);
                sendGetDepartmentDetailTask(ConfigUtilHelper.getMobile(app),
                    area_type_str, department.dep_id);
                break;
            case 2:
                if (isLocal)
                {
                    doctor = choiceDoctorAdapter.schList.get(position).doctor;
                }
                else
                {
                    doctor = choiceDoctorAdapter.docList.get(position);
                }
                sendGetDoctorDetailTask(ConfigUtilHelper.getMobile(app),
                    area_type_str, doctor.dep_id, doctor.doctor_id);
                break;
            case 3:
                break;
            }
        }
    };

    /**
     * 初始化参数
     * @param parameterMap
     * @return
     */
    private Map<String, String> initArgMap(Map<String, String> parameterMap)
    {
        parameterMap.put("userId", Arguments.userId);
        parameterMap.put("timestamp", ConfigUtilHelper.getStringNow());
        parameterMap.put("userPwd", ConfigUtilHelper.getUserPwd());
        parameterMap.put("pageSize", Arguments.pageSize);
        return parameterMap;
    }

    /**
     * 初始化参数
     * @param parameterMap
     * @return
     */
    private Map<String, String> initArgMap_sch(Map<String, String> parameterMap)
    {
        parameterMap.put("userId", Arguments.userId);
        parameterMap.put("timestamp", ConfigUtilHelper.getStringNow());
        parameterMap.put("userPwd", ConfigUtilHelper.getUserPwd());
        return parameterMap;
    }

    /**
     * 获取异地城市列表
     */
    private MyAsynaTask asnTask;

    /**
     * page 表示第几页
     * @param page
     */
    private void sendSearchAreaListTask(int page)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap = initArgMap(parameterMap);
        parameterMap.put("page", Integer.toString(page));
        parameterMap.put("methodVit", Arguments.GetAreas);
        asnTask = new MyAsynaTask(this, GlobalSetting.XML_GET_OTHER_AREA,
            parameterMap);
        asnTask.execute();
    }

    /**
     * 发送异地医院列表
     * @param page
     */
    private void sendSearchHospitalListTask(int page)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap = initArgMap(parameterMap);
        parameterMap.put("page", Integer.toString(page));
        parameterMap.put("methodVit", Arguments.GetHospitals);
        parameterMap.put("areaId", area_id);
        asnTask = new MyAsynaTask(this, GlobalSetting.XML_GET_OTHER_HOSPITAL,
            parameterMap);
        asnTask.execute();
    }

    /**
     * 发送异地科室列表
     * @param page
     */
    private void sendSearchDepListTask(int page)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap = initArgMap(parameterMap);
        parameterMap.put("page", Integer.toString(page));
        parameterMap.put("methodVit", Arguments.GetDepartments);
        parameterMap.put("hospitalId", unit_id);
        asnTask = new MyAsynaTask(this, GlobalSetting.XML_GET_OTHER_DEP,
            parameterMap);
        asnTask.execute();
    }

    /**
     * 发送异地医生列表
     * @param page
     */
    private void sendSearchDocListTask(int page, int outType)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap = initArgMap(parameterMap);
        parameterMap.put("page", Integer.toString(page));
        parameterMap.put("methodVit", Arguments.GetDoctors);
        parameterMap.put("deptId", dep_id);
        if (outType == 0)
        {// 普通门诊
            parameterMap.put("outType", getString(R.string.common_outtype));
        }
        else
        {// 专家门诊
            parameterMap.put("outType", getString(R.string.profession_outtype));
        }
        asnTask = new MyAsynaTask(this, GlobalSetting.XML_GET_OTHER_DOC,
            parameterMap);
        asnTask.execute();
    }

    /**
     * 发送异地排班列表
     * @param page
     */
    private void sendSearchSchListTask(int page)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap = initArgMap(parameterMap);
        parameterMap.put("methodVit", Arguments.GetSchedules);
        parameterMap.put("doctorId", doc_id);
        parameterMap.put("page", Integer.toString(page));
        asnTask = new MyAsynaTask(this, GlobalSetting.XML_GET_OTHER_SCH,
            parameterMap);
        asnTask.execute();
    }

    /**
     * 获取异地医院详情
     * @param page
     */
    private void getHosInfoTask(int p)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap = initArgMap_sch(parameterMap);
        parameterMap.put("methodVit", Arguments.GetHospitalInfo);
        parameterMap.put("hospitalId", hospitalList.get(p).hospitalid);
        asnTask = new MyAsynaTask(this, GlobalSetting.XML_GET_OTHER_HOS_INFO,
            parameterMap);
        showProgressDialog();
        asnTask.execute();
    }

    /**
     * 获取异地医生详情
     * @param page
     */
    private void getDocInfoTask(int p)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap = initArgMap_sch(parameterMap);
        parameterMap.put("methodVit", Arguments.GetDoctorInfo);
        if (outType == 0)
        {
            parameterMap.put("doctorId", docList_common.get(p).doctorId);
        }
        else
        {
            parameterMap.put("doctorId", docList_profession.get(p).doctorId);
        }
        asnTask = new MyAsynaTask(this, GlobalSetting.XML_GET_OTHER_DOC_INFO,
            parameterMap);
        showProgressDialog();
        asnTask.execute();
    }

    /**
     * 获取医院信息
     */
    private HttpAsyncTask sendGetHospitalDetailTask;

    /**
     * 
     * @param mobile 手机号码 如果为空，则不处理关注相关数据
     * @param area_type 区域类别 0：本地 1：异地
     * @param unit_id 医院编号
     */
    private void sendGetHospitalDetailTask(String mobile, String area_type,
        String unit_id)
    {
        logger.d("----------sendGetHospitalDetailTask----------");
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("area_type", area_type);
        parameterMap.put("mobile", mobile);
        parameterMap.put("unit_id", unit_id);
        String getHospitalDetailUrl = Utils.changeUrl(
            Arguments.SERVER_URL_GET_HOSPITAL_DETAIL, parameterMap);
        sendGetHospitalDetailTask = new HttpAsyncTask(HttpAsyncTask.GET,
            GlobalSetting.XML_HOSPITAL_DETAIL, getHospitalDetailUrl,
            HttpAsyncTask.CACHE_TYPE_ACTION, false);
        showProgressDialog();
        sendGetHospitalDetailTask
            .setUIHandler(sendGetHospitalDetailTaskHandler);
        mHttpManager.execute(sendGetHospitalDetailTask);
    }

    @SuppressWarnings("unchecked")
    Handler sendGetHospitalDetailTaskHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            logger.d("----------sendGetHospitalDetailTaskHandler----------");
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                dismissProgressDialog();
                if (msg.obj != null)
                {
                    try
                    {
                        Map<String, Object> httpMap = (Map<String, Object>) msg.obj;
                        Hospital hospital_1 = (Hospital) httpMap
                            .get(Arguments.XML_HOSPITAL);
                        hospital_1.image = hospital.image;
                        showHospitalInfoDialog(hospital_1);
                    }
                    catch (Exception e)
                    {
                        e.printStackTrace();
                        showSingleAlertDlg(getString(R.string.notice),
                            getString(R.string.read_fail),
                            getString(R.string.close));
                    }
                }
                else
                {
                    showSingleAlertDlg(getString(R.string.notice),
                        getString(R.string.read_fail),
                        getString(R.string.close));
                }
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.read_fail), getString(R.string.close));
                break;
            }
        }
    };

    /**
     * 查询名医名院
     */
    private HttpAsyncTask sendSearchTask;

    /**
     * @param area_type 区域类别 N 0：本地 1：异地
     * @param search_type 查询类别 N 0:搜索医院1:搜索科室2:搜索医生
     * @param area_id 医院区域 Y 本地: 7罗湖区，3317福田区，3318盐田区，3319龙岗区，8南山区，3320宝安区，3321
     *        光明新区； 异地： 1 广州，6北京，7上海，9武汉，5长沙，10成都，11西安，8重庆
     * @param unit_level 医院级别 Y
     * @param cat_no 科室分类 Y
     *        A内科；B外科；C肿瘤科；D妇产科；E儿科；F五官科；G男科；H传染科；I皮肤性病；J精神心理科K中西医结合科
     *        L生殖健康M急诊科N老年科
     * @param search_content 查询内容 Y
     * @param page 页数 N 0 表示不分页为所有，分页从1开始
     * @param pageSize 每页记录数 11 Y 默认为10
     */
    private void sendSearchTask(Map<String, String> parameterMap, int cache_type)
    {
        String searchUrl = Utils.changeUrl(
            Arguments.SERVER_URL_SEARCH_FRMOUS_HOSPITAL, parameterMap);
        if (ConfigUtilHelper.debug)
        {
            Log.i(TAG, "查询名医名院URL:" + searchUrl);
        }
        if (cache_type == HttpAsyncTask.CACHE_TYPE_ACTION)
        {
            sendSearchTask = new HttpAsyncTask(HttpAsyncTask.GET,
                GlobalSetting.XML_SEARCH, searchUrl, cache_type, true);
        }
        else
        {
            sendSearchTask = new HttpAsyncTask(HttpAsyncTask.GET,
                GlobalSetting.XML_SEARCH, searchUrl, cache_type, false);
        }
        sendSearchTask.setUIHandler(sendSearchTaskHandler);
        mHttpManager.execute(sendSearchTask);
    }

    private void sendSearchHospitalTask(String area_type, String area_id,
        String unit_level, String search_content, String page, int cache_type)
    {
        logger.d("----------sendSearchHospitalTask----------" + page);
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("area_type", area_type);
        parameterMap.put("search_type", "0");
        parameterMap.put("area_id", area_id);
        parameterMap.put("unit_level", unit_level);
        parameterMap.put("search_content", search_content);
        parameterMap.put("page", page);
        parameterMap.put("pageSize", Arguments.pageSize);
        parameterMap.put("mobile", ConfigUtilHelper.getMobile(app));
        sendSearchTask(parameterMap, cache_type);
    }

    @SuppressWarnings("unchecked")
    Handler sendSearchTaskHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            logger.d("----------sendSearchTaskHandler----------");
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                dismissProgressDialog();
                List<Hospital> hospitalList_2 = new ArrayList<Hospital>();
                if (msg.obj != null)
                {
                    try
                    {
                        Map<String, Object> httpMap = (Map<String, Object>) msg.obj;
                        allPage = Integer.parseInt((String) httpMap
                            .get(Arguments.XML_ALLPAGE));
                        currPage = Integer.parseInt((String) httpMap
                            .get(Arguments.XML_CURRPAGE));
                        List<Hospital> hospitalList_1 = (List<Hospital>) httpMap
                            .get(Arguments.XML_HOSPITAL_LIST);

                        if ("0".equals(area_type_str))
                        {
                            for (Hospital h : hospitalList_1)
                            {
                                /*
                                 * if (!"0".equals(h.left_num)) {
                                 * Log.i(TAG,"add"); hospitalList_2.add(h); }
                                 */
                                hospitalList_2.add(h);
                            }
                        }
                        else
                        {
                            hospitalList_2 = hospitalList_1;
                        }
                        if (currPage == 1)
                        {
                            hospitalMap.put(currentSelectPosition,
                                hospitalList_2);
                        }
                        else
                        {
                            hospitalMap.get(currentSelectPosition).addAll(
                                hospitalList_2);
                        }
                    }
                    catch (Exception e)
                    {
                        e.printStackTrace();
                        allPage = currPage;
                    }
                }
                else {
                    showNoData(true);
                    return;
                }
                setView();
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.read_fail), getString(R.string.close));
                allPage = currPage;
                setView();
                break;
            }
        }
    };

    /**
     * 获取科室列表
     */
    private HttpAsyncTask sendGetDepartmentListTask;

    /**
     * 
     * @param area_type 区域类别 0：本地 1：异地 2 所有
     * @param mobile 手机号码 如果为空，则不处理关注相关数据
     * @param unit_id 医院id 如果为空，获取所有的科室， 如果不为空，获取所在医院的科室
     * @param is_attention 是否已关注 缺省时查询全部，1只返回已关注数据
     * @param page 页数 0 表示不分页为所有，分页从1开始
     * @param pageSize 每页记录数 默认为10
     */
    protected void sendGetDepartmentListTask(String area_type, String mobile,
        String unit_id, String is_attention, String page, int cache_type)
    {
        logger.d("----------sendGetDepartmentListTask----------" + page);
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("area_type", area_type);
        parameterMap.put("mobile", mobile);
        parameterMap.put("unit_id", unit_id);
        parameterMap.put("is_attention", is_attention);
        parameterMap.put("page", page);
        parameterMap.put("pageSize", Arguments.pageSize);
        String getDepartmentListUrl = Utils.changeUrl(
            Arguments.SERVER_URL_GET_DEPARTMENT_LIST, parameterMap);

        if (cache_type == HttpAsyncTask.CACHE_TYPE_ACTION)
        {
            sendGetDepartmentListTask = new HttpAsyncTask(HttpAsyncTask.GET,
                GlobalSetting.XML_DEPARTMENT_LIST, getDepartmentListUrl,
                cache_type, true);
        }
        else
        {
            sendGetDepartmentListTask = new HttpAsyncTask(HttpAsyncTask.GET,
                GlobalSetting.XML_DEPARTMENT_LIST, getDepartmentListUrl,
                cache_type, false);
        }
        sendGetDepartmentListTask
            .setUIHandler(sendGetDepartmentListTaskHandler);
        mHttpManager.execute(sendGetDepartmentListTask);
    }

    @SuppressWarnings("unchecked")
    Handler sendGetDepartmentListTaskHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            logger.d("----------sendGetDepartmentListTaskHandler----------");
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                dismissProgressDialog();
                if (msg.obj != null)
                {
                    try
                    {
                        Map<String, Object> httpMap = (Map<String, Object>) msg.obj;
                        allPage = Integer.parseInt((String) httpMap
                            .get(Arguments.XML_ALLPAGE));
                        currPage = Integer.parseInt((String) httpMap
                            .get(Arguments.XML_CURRPAGE));
                        List<Department> departmentList_1 = (List<Department>) httpMap
                            .get(Arguments.XML_DEPARTMENT_LIST);
                        List<Department> departmentList_2 = new ArrayList<Department>();
                        if ("0".equals(area_type_str))
                        {
                            for (Department d : departmentList_1)
                            {
                                /*
                                 * if (!"0".equals(d.left_num)) {
                                 * departmentList_2.add(d); }
                                 */
                                departmentList_2.add(d);
                            }
                        }
                        else
                        {
                            departmentList_2 = departmentList_1;
                        }
                        if (currPage == 1)
                        {
                            departmentList = departmentList_2;
                        }
                        else
                        {
                            departmentList.addAll(departmentList_2);
                        }
                    }
                    catch (Exception e)
                    {
                        e.printStackTrace();
                        allPage = currPage;
                    }
                }
                setView();
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.read_fail), getString(R.string.close));
                allPage = currPage;
                setView();
                break;
            }
        }
    };

    /**
     * 获取科室信息
     */
    private HttpAsyncTask sendGetDepartmentDetailTask;

    /**
     * 
     * @param mobile 手机号码 如果为空，则不处理关注相关数据
     * @param area_type 区域类别 0：本地 1：异地
     * @param dep_id 科室id
     */
    private void sendGetDepartmentDetailTask(String mobile, String area_type,
        String dep_id)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("area_type", area_type);
        parameterMap.put("mobile", mobile);
        parameterMap.put("dep_id", dep_id);
        String getDepartmentDetailUrl = Utils.changeUrl(
            Arguments.SERVER_URL_GET_DEPARTMENT_DETAIL, parameterMap);
        sendGetDepartmentDetailTask = new HttpAsyncTask(HttpAsyncTask.GET,
            GlobalSetting.XML_DEPARTMENT_DETAIL, getDepartmentDetailUrl,
            HttpAsyncTask.CACHE_TYPE_ACTION, false);
        showProgressDialog();
        sendGetDepartmentDetailTask
            .setUIHandler(sendGetDepartmentDetailTaskHandler);
        mHttpManager.execute(sendGetDepartmentDetailTask);
    }

    @SuppressWarnings("unchecked")
    Handler sendGetDepartmentDetailTaskHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            logger.d("----------sendGetDepartmentDetailTaskHandler----------");
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                dismissProgressDialog();
                if (msg.obj != null)
                {
                    try
                    {
                        Map<String, Object> httpMap = (Map<String, Object>) msg.obj;
                        Department department_1 = (Department) httpMap
                            .get(Arguments.XML_DEPARTMENT);
                        department.dep_intro = department_1.dep_intro;
                        showDepartmentInfoDialog(department);
                    }
                    catch (Exception e)
                    {
                        e.printStackTrace();
                        showSingleAlertDlg(getString(R.string.notice),
                            getString(R.string.read_fail),
                            getString(R.string.close));
                    }
                }
                else
                {
                    showSingleAlertDlg(getString(R.string.notice),
                        getString(R.string.read_fail),
                        getString(R.string.close));
                }
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.read_fail), getString(R.string.close));
                break;
            }
        }
    };

    /**
     * 获取医生列表
     */
    private HttpAsyncTask sendGetDoctorListTask;

    /**
     * 
     * @param area_type 区域类别 0：本地 1：异地 2 所有
     * @param mobile 手机号码 如果为空，则不处理关注相关数据
     * @param unit_id 医院id 如果为空，获取所有的科室， 如果不为空，获取所在医院的科室
     * @param dep_id 科室id 如果为空，获取所有的医生， 如果不为空，获取所在科室的医生
     * @param is_attention 是否已关注 缺省时查询全部，1只返回已关注数据
     * @param page 页数 0 表示不分页为所有，分页从1开始
     * @param pageSize 每页记录数 默认为10
     */
    protected void sendGetDoctorListTask(String area_type, String mobile,
        String unit_id, String dep_id, String is_attention, String page,
        int cache_type)
    {
        logger.d("----------sendGetDoctorListTask----------");
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("area_type", area_type);
        parameterMap.put("mobile", mobile);
        parameterMap.put("unit_id", unit_id);
        parameterMap.put("dep_id", dep_id);
        parameterMap.put("is_attention", is_attention);
        parameterMap.put("page", page);
        parameterMap.put("pageSize", Arguments.pageSize);
        String getDoctorListUrl = Utils.changeUrl(
            Arguments.SERVER_URL_GET_DOCTOR_LIST, parameterMap);
        if (ConfigUtilHelper.debug)
        {
            Log.i(TAG, "获取医生列表url：" + getDoctorListUrl);
        }
        if (cache_type == HttpAsyncTask.CACHE_TYPE_ACTION)
        {
            sendGetDoctorListTask = new HttpAsyncTask(HttpAsyncTask.GET,
                GlobalSetting.XML_DOCTOR_LIST, getDoctorListUrl, cache_type,
                true);
        }
        else
        {
            sendGetDoctorListTask = new HttpAsyncTask(HttpAsyncTask.GET,
                GlobalSetting.XML_DOCTOR_LIST, getDoctorListUrl, cache_type,
                false);
        }
        sendGetDoctorListTask.setUIHandler(sendGetDoctorListTaskHandler);
        mHttpManager.execute(sendGetDoctorListTask);
    }

    @SuppressWarnings("unchecked")
    Handler sendGetDoctorListTaskHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            logger.d("----------sendGetDoctorListTaskHandler----------");
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                dismissProgressDialog();
                if (msg.obj != null)
                {
                    try
                    {
                        Map<String, Object> httpMap = (Map<String, Object>) msg.obj;
                        allPage = Integer.parseInt((String) httpMap
                            .get(Arguments.XML_ALLPAGE));
                        currPage = Integer.parseInt((String) httpMap
                            .get(Arguments.XML_CURRPAGE));
                        List<Doctor> doctorList_1 = (List<Doctor>) httpMap
                            .get(Arguments.XML_DOCTOR_LIST);
                        if (currPage == 1)
                        {
                            doctorList = doctorList_1;
                        }
                        else
                        {
                            doctorList.addAll(doctorList_1);
                        }
                    }
                    catch (Exception e)
                    {
                        e.printStackTrace();
                        allPage = currPage;
                    }
                }
                setView();
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.read_fail), getString(R.string.close));
                allPage = currPage;
                setView();
                break;
            }
        }
    };

    /**
     * 获取医生信息
     */
    private HttpAsyncTask sendGetDoctorDetailTask;

    /**
     * 
     * @param mobile 手机号码 如果为空，则不处理关注相关数据
     * @param area_type 区域类别 0：本地 1：异地
     * @param dep_id 科室id
     * @param doctor_id 医生id
     */
    private void sendGetDoctorDetailTask(String mobile, String area_type,
        String dep_id, String doctor_id)
    {
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("area_type", area_type);
        parameterMap.put("mobile", mobile);
        parameterMap.put("dep_id", dep_id);
        parameterMap.put("doctor_id", doctor_id);
        String getDoctorDetailUrl = Utils.changeUrl(
            Arguments.SERVER_URL_GET_DOCTOR_DETAIL, parameterMap);
        sendGetDoctorDetailTask = new HttpAsyncTask(HttpAsyncTask.GET,
            GlobalSetting.XML_DOCTOR_DETAIL, getDoctorDetailUrl,
            HttpAsyncTask.CACHE_TYPE_SAVE, false);
        sendGetDoctorDetailTask.setUIHandler(sendGetDoctorDetailTaskHandler);
        mHttpManager.execute(sendGetDoctorDetailTask);
    }

    @SuppressWarnings("unchecked")
    Handler sendGetDoctorDetailTaskHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            logger.d("----------sendGetDoctorDetailTaskHandler----------");
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                dismissProgressDialog();
                if (msg.obj != null)
                {
                    try
                    {
                        Map<String, Object> httpMap = (Map<String, Object>) msg.obj;
                        String detail = (String) httpMap
                            .get(Arguments.XML_DETAIL);
                        doctor.detail = detail;
                        showDoctorInfoDialog(doctor);
                    }
                    catch (Exception e)
                    {
                        e.printStackTrace();
                        showSingleAlertDlg(getString(R.string.notice),
                            getString(R.string.read_fail),
                            getString(R.string.close));
                    }
                }
                else
                {
                    showSingleAlertDlg(getString(R.string.notice),
                        getString(R.string.read_fail),
                        getString(R.string.close));
                }
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.read_fail), getString(R.string.close));
                break;
            }
        }
    };

    /**
     * 查询出诊班次的号源信息
     */
    private HttpAsyncTask sendGetScheduleListTask;

    /**
     * 
     * @param unit_id 医院ID
     * @param schedule_id 班次
     */
    private void sendGetScheduleListTask(String unit_id, String schedule_id)
    {
        logger.d("----------sendGetScheduleListTask----------");
        Map<String, String> parameterMap = new HashMap<String, String>();
        parameterMap.put("unit_id", unit_id);
        parameterMap.put("schedule_id", schedule_id);
        String getScheduleListUrl = Utils.changeUrl(
            Arguments.SERVER_URL_GET_SCHEDULE_LIST, parameterMap);
        if (ConfigUtilHelper.debug)
        {
            Log.i(TAG, "查询出诊班次地址：" + getScheduleListUrl);
        }
        sendGetScheduleListTask = new HttpAsyncTask(HttpAsyncTask.GET,
            GlobalSetting.XML_SCHEDULE_LIST, getScheduleListUrl,
            HttpAsyncTask.CACHE_TYPE_SAVE, false);
        sendGetScheduleListTask.setUIHandler(sendGetScheduleListTaskHandler);
        mHttpManager.execute(sendGetScheduleListTask);
    }

    @SuppressWarnings("unchecked")
    Handler sendGetScheduleListTaskHandler = new Handler() {
        public void handleMessage(Message msg)
        {
            logger.d("----------sendGetScheduleListTaskHandler----------");
            switch (msg.what)
            {
            case HttpAsyncTask.TASK_NOTIFY_RETURN_DATA:
                dismissProgressDialog();
                if (msg.obj != null)
                {
                    try
                    {
                        Map<String, Object> httpMap = (Map<String, Object>) msg.obj;
                        List<Schedule> scheduleList_1 = (List<Schedule>) httpMap
                            .get(Arguments.XML_SCHEDULE_LIST);
                        if (currPage == 1)
                        {
                            scheduleList = scheduleList_1;
                        }
                        else
                        {
                            scheduleList.addAll(scheduleList_1);
                        }
                    }
                    catch (Exception e)
                    {
                        e.printStackTrace();
                        allPage = currPage;
                    }
                }
                setView();
                break;
            case HttpAsyncTask.TASK_NOTIFY_CONNECTION_FAIL:
                dismissProgressDialog();
                showSingleAlertDlg(getString(R.string.notice),
                    getString(R.string.read_fail), getString(R.string.close));
                allPage = currPage;
                setView();
                break;
            }
        }
    };

    @Override
    protected void setTaskHandlerNull()
    {
        if (sendGetHospitalDetailTask != null)
        {
            sendGetHospitalDetailTask.setTaskBindingHandler(null);
        }
        if (sendGetDepartmentDetailTask != null)
        {
            sendGetDepartmentDetailTask.setTaskBindingHandler(null);
        }
        if (sendGetDoctorListTask != null)
        {
            sendGetDoctorListTask.setTaskBindingHandler(null);
        }
        if (sendSearchTask != null)
        {
            sendSearchTask.setTaskBindingHandler(null);
        }
        if (sendGetDepartmentListTask != null)
        {
            sendGetDepartmentListTask.setTaskBindingHandler(null);
        }
        if (sendGetDoctorDetailTask != null)
        {
            sendGetDoctorDetailTask.setTaskBindingHandler(null);
        }
        if (sendGetScheduleListTask != null)
        {
            sendGetScheduleListTask.setTaskBindingHandler(null);
        }
    }

    /**
     * 回调获取城市的结果并显示
     */
    @Override
    public void updateData_CityList(AreaResultModel mAreaResultModel)
    {
        // TODO Auto-generated method stub
        dismissProgressDialog();
        if (mAreaResultModel.areaList.size() > 0)
        {
            boolean isEnd = true;
            if (currPage * Integer.parseInt(Arguments.pageSize) < mAreaResultModel.totalCount)
            {
                isEnd = false;
            }
            else
            {
                isEnd = true;
            }
            this.areaList.addAll(mAreaResultModel.areaList);
            if (choiceAreaAdapter == null)
            {
                choiceAreaAdapter = new ChoiceAreaAdapter(this, areaList,
                    isEnd, this);
                listview.setAdapter(choiceAreaAdapter);
            }
            else
            {
                choiceAreaAdapter.isEnd = isEnd;
                choiceAreaAdapter.notifyDataSetChanged();
            }
            showNoData(false);
        }
        else
        {
            showNoData(true);
        }
    }

    /**
     * 继续下一页数据
     */
    @Override
    public void next_updateData()
    {
        // TODO Auto-generated method stub
        currPage += 1;
        sendSearchAreaListTask(currPage);
    }

    /**
     * 回调返回异地医院函数
     */
    @Override
    public void updateData_HospitalList(HospitalResultModel mHospitalResultModel)
    {
        // TODO Auto-generated method stub
        dismissProgressDialog();
        if (mHospitalResultModel.hospitalList.size() > 0)
        {
            boolean isEnd = true;
            if (currPage * Integer.parseInt(Arguments.pageSize) < mHospitalResultModel.totalCount)
            {
                isEnd = false;
            }
            else
            {
                isEnd = true;
            }
            this.hospitalList.addAll(mHospitalResultModel.hospitalList);
            if (choiceOtherHospitalAdapter == null)
            {
                choiceOtherHospitalAdapter = new ChoiceOtherHospitalAdapter(
                    this, hospitalList, isEnd, this);
                listview.setAdapter(choiceOtherHospitalAdapter);
            }
            else
            {
                choiceOtherHospitalAdapter.isEnd = isEnd;
                choiceOtherHospitalAdapter.notifyDataSetChanged();
            }
            showNoData(false);
        }
        else
        {
            no_data_txt.setText(R.string.no_sch_data_text);
            showNoData(true);
        }
    }

    /**
     * 加载下一页异地医院
     */
    @Override
    public void next_updateData_Hospital()
    {
        // TODO Auto-generated method stub
        currPage += 1;
        sendSearchHospitalListTask(currPage);
    }

    /**
     * 回调返回异地科室函数
     */
    @Override
    public void updateData_DepList(DepResultModel mDepModelResult)
    {
        // TODO Auto-generated method stub
        dismissProgressDialog();
        if (mDepModelResult.depList.size() > 0)
        {
            boolean isEnd = true;
            if (currPage * Integer.parseInt(Arguments.pageSize) < mDepModelResult.totalCount)
            {
                isEnd = false;
            }
            else
            {
                isEnd = true;
            }
            this.depList.addAll(mDepModelResult.depList);
            if (choiceOtherDepAdapter == null)
            {
                choiceOtherDepAdapter = new ChoiceOtherDepAdapter(this,
                    depList, isEnd, this);
                listview.setAdapter(choiceOtherDepAdapter);
            }
            else
            {
                choiceOtherDepAdapter.isEnd = isEnd;
                choiceOtherDepAdapter.notifyDataSetChanged();
            }
            showNoData(false);
        }
        else
        {
            showNoData(true);
        }
    }

    /**
     * 加载下一页异地科室
     */
    @Override
    public void next_updateData_Dep()
    {
        // TODO Auto-generated method stub
        currPage += 1;
        sendSearchDepListTask(currPage);
    }

    /**
     * 回调返回异地医生函数
     */
    @Override
    public void updateData_DocList(DocResultModel mDocResultModel)
    {
        // TODO Auto-generated method stub
        dismissProgressDialog();
        if (mDocResultModel.docList.size() > 0)
        {

            boolean isEnd = true;

            if (mDocResultModel.docList.get(0).outType
                .equals(getString(R.string.common_outtype)))
            {// 普通门诊
                doc_totalcount_c = mDocResultModel.totalCount;
                if (currPage_c * Integer.parseInt(Arguments.pageSize) < mDocResultModel.totalCount)
                {
                    isEnd = false;
                }
                else
                {
                    isEnd = true;
                }
                this.docList_common.addAll(mDocResultModel.docList);
                if (choiceOtherDocAdapter_common == null)
                {
                    choiceOtherDocAdapter_common = new ChoiceOtherDocAdapter(
                        this, docList_common, isEnd, this);
                    listview.setAdapter(choiceOtherDocAdapter_common);
                }
                else
                {
                    choiceOtherDocAdapter_common.isEnd = isEnd;
                    choiceOtherDocAdapter_common.notifyDataSetChanged();
                }
            }
            else
            {
                doc_totalcount_p = mDocResultModel.totalCount;
                if (currPage_p * Integer.parseInt(Arguments.pageSize) < mDocResultModel.totalCount)
                {
                    isEnd = false;
                }
                else
                {
                    isEnd = true;
                }
                this.docList_profession.addAll(mDocResultModel.docList);
                if (choiceOtherDocAdapter_profession == null)
                {
                    choiceOtherDocAdapter_profession = new ChoiceOtherDocAdapter(
                        this, docList_profession, isEnd, this);
                    listview.setAdapter(choiceOtherDocAdapter_profession);
                }
                else
                {
                    choiceOtherDocAdapter_profession.isEnd = isEnd;
                    choiceOtherDocAdapter_profession.notifyDataSetChanged();
                }
            }
            showNoData(false);
        }
        else
        {
            if (isInit)
            {
                isInit = false;
                initLoadCommon();
            }
            else
            {
                no_data_txt.setText(R.string.no_sch_data_text);
                showNoData(true);
            }
        }
    }

    /**
     * 加载普通门诊（主要用于当发现专家门诊号源不存在的回来加载普通门诊的情况）
     */
    private void initLoadCommon()
    {
        zhuanjia_bg.setBackgroundResource(R.drawable.zhuanjia);
        putong_bg.setBackgroundResource(R.drawable.putong_press);
        zhuanjia_txt.setTextColor(getResources().getColor(R.color.gray));
        putong_txt.setTextColor(getResources().getColor(R.color.sky_blue));
        outType = 0;
        if (docList_common.size() == 0)
        {
            currPage_c = 1;
            showProgressDialog();
            sendSearchDocListTask(currPage_c, outType);
        }
        else
        {
            boolean isEnd = true;
            if (currPage_c * Integer.parseInt(Arguments.pageSize) < doc_totalcount_c)
            {
                isEnd = false;
            }
            else
            {
                isEnd = true;
            }
            showNoData(false);
            choiceOtherDocAdapter_common = new ChoiceOtherDocAdapter(
                ChoiceActivity.this, docList_common, isEnd, ChoiceActivity.this);
            listview.setAdapter(choiceOtherDocAdapter_common);
        }
    }

    /**
     * 加载下一页异地医生
     */
    @Override
    public void next_updateData_Doc()
    {
        // TODO Auto-generated method stub
        if (outType == 0)
        {
            currPage_c += 1;
            sendSearchDocListTask(currPage_c, outType);
        }
        else
        {
            currPage_p += 1;
            sendSearchDocListTask(currPage_p, outType);
        }

    }

    /**
     * 回调返回异地排班函数
     */
    @Override
    public void updateData_ScheduleList(ScheduleResultModel mScheduleResultModel)
    {
        // TODO Auto-generated method stub
        dismissProgressDialog();
        if (mScheduleResultModel.schList.size() > 0)
        {
            boolean isEnd = true;
            if (currPage * Integer.parseInt(Arguments.pageSize) < mScheduleResultModel.totalCount)
            {
                isEnd = false;
            }
            else
            {
                isEnd = true;
            }
            this.schList.addAll(mScheduleResultModel.schList);
            if (choiceOtherSchAdapter == null)
            {
                choiceOtherSchAdapter = new ChoiceOtherSchAdapter(this,
                    schList, isEnd, this);
                listview.setAdapter(choiceOtherSchAdapter);
            }
            else
            {
                choiceOtherSchAdapter.isEnd = isEnd;
                choiceOtherSchAdapter.notifyDataSetChanged();
            }
            showNoData(false);
        }
        else
        {
            no_data_txt.setText(R.string.no_sch_data_text);
            showNoData(true);
        }
    }

    /**
     * 加载下一页异地班次
     */
    @Override
    public void next_updateData_Schedule()
    {
        // TODO Auto-generated method stub
        currPage += 1;
        sendSearchSchListTask(currPage);

    }

    /**
     * 回调医院详情
     */
    @Override
    public void callback_hospital_info(int p)
    {
        // TODO Auto-generated method stub
        getHosInfoTask(p);
    }

    /**
     * 回调医生详情
     */
    @Override
    public void callback_doc_info(int p)
    {
        // TODO Auto-generated method stub
        getDocInfoTask(p);
    }

    /**
     * 获取医院详情并显示
     */
    @Override
    public void get_hospital_info(HospitalInfoModel hospitalInfoModel)
    {
        // TODO Auto-generated method stub
        showOtherHospitalInfoDialog(hospitalInfoModel);
    }

    /**
     * 获取医生详情并显示
     */
    @Override
    public void get_doc_info(DocInfoModel docInfoModel)
    {
        // TODO Auto-generated method stub
        showOtherDocInfoDialog(docInfoModel);
    }

    /**
     * 显示异地医院详情
     * @param hospitalInfoModel
     */
    private void showOtherHospitalInfoDialog(HospitalInfoModel hospitalInfoModel)
    {
        dismissProgressDialog();
        dialog = new HospitalInfoDialog(this, hospitalInfoModel);
        if (dialog != null)
        {
            dialog.show();
        }
    }

    /**
     * 显示异地医生详情
     * @param docInfoModel
     */
    private void showOtherDocInfoDialog(DocInfoModel docInfoModel)
    {
        dismissProgressDialog();
        dialog = new DoctorInfoDialog(this, docInfoModel);
        if (dialog != null)
        {
            dialog.show();
        }
    }
}